import type { 
  IUsed,
  AsyncDataResult,
  AsyncVoid,
  GetTableUsedParams,
  SetTableUsedParams
} from '../../types'
import { HttpClient } from '../../HttpClient'

export class UsedAPI implements IUsed {
  private httpClient: HttpClient

  constructor(httpClient: HttpClient) {
    this.httpClient = httpClient
  }
  async get(table: string): AsyncDataResult<number> {
    return await this.httpClient.request<GetTableUsedParams>('get_tables_used', { table })
  }
  async use(table: string, id: string): AsyncVoid {
    return await this.httpClient.request<SetTableUsedParams>('set_tables_used', {
      table,
      primaryKeyValue: id
    })
  }

}
